(ns ru.nsu.fit.g7202.seml-test
  (:use clojure.test
        ru.nsu.fit.g7202.test.assert)
  (:require [ru.nsu.fit.g7202.seml :as seml]))

;; FYI docs: http://richhickey.github.com/clojure/clojure.test-api.html

(deftest parseFile-test
  (let [
        filename "Data/input.seml"
        expected-obj '{people [{firstName "Иван", lastName "Иванов", addrs [{streetAddress "Пирогова, 2", city "Новосибирск", postalCode 630090} {streetAddress "Пирогова, 3", city "Новосибирск", postalCode 630090}], phoneNumbers ["812 123-1234" "916 123-4567"]} {firstName "Пётр", lastName "Петров", addrs [], phoneNumbers []}]}
       ]
    (assert-eq expected-obj (seml/parseFile filename))
  ))

(deftest parseString-test
  (let [
        str "{people [{firstName \"Иван\", lastName \"Иванов\", addrs [{streetAddress \"Пирогова, 2\", city \"Новосибирск\", postalCode 630090} {streetAddress \"Пирогова, 3\", city \"Новосибирск\", postalCode 630090}], phoneNumbers [\"812 123-1234\" \"916 123-4567\"]} {firstName \"Пётр\", lastName \"Петров\", addrs [], phoneNumbers []}]}"
        expected-obj '{people [{firstName "Иван", lastName "Иванов", addrs [{streetAddress "Пирогова, 2", city "Новосибирск", postalCode 630090} {streetAddress "Пирогова, 3", city "Новосибирск", postalCode 630090}], phoneNumbers ["812 123-1234" "916 123-4567"]} {firstName "Пётр", lastName "Петров", addrs [], phoneNumbers []}]}
       ]
    (assert-eq expected-obj (seml/parseString str))
  ))
